#include <bits/stdc++.h>
using namespace std;
using ll = long long int;
ll q;
ll num;
ll cnt[10];
ll solve()
{
    memset(cnt, 0, sizeof(cnt));
    if (num % 2 == 0)
        return num;
    ll tem = num;
    while (tem)
    {
        cnt[tem % 10]++;
        tem /= 10;
    }
    bool flag = false;
    for (int i = 0; i < 10; i++)
    {
        if (cnt[i] > 0)
        {
            if (i % 2 == 0)
            {
                flag = true;
                break;
            }
        }
    }
    if (flag)
    {
        ll lastnum;
        string ret;
        for (int i = 0; i < 10; i++)
        {
            if (cnt[i] > 0 && i % 2 == 0)
            {
                lastnum = i;
                break;
            }
        }
        for (int i = 0; i < 10; i++)
        {
            if (cnt[i] > 0 && i != lastnum)
            {
                int h = cnt[i];
                while (h--)
                {
                    ret.push_back(i + '0');
                }
            }
        }
        int h = cnt[lastnum];
        while (h--) ret.push_back(lastnum+'0');
       
        return std::stol(ret);
    }
    else
    {
        return -1;
    }
}

int main()
{
    cin >> q;
    while (q--)
    {
        cin >> num;
        cout << solve() << endl;
    }
    return 0;
}